<template>
    <!--  默认为10, 传值则使用传的数据   -->
    <van-pagination v-model="pageIndex"
        style="margin-top: 10px"
        :total-items="totalRecord"
        :items-per-page="pageSizeCount || pageSize"
        force-ellipses
        @change="handleChange">
        <template #prev-text>
            <van-icon name="arrow-left" />
        </template>
        <template #next-text>
            <van-icon name="arrow" />
        </template>
    </van-pagination>

</template>

<script>
export default {
  name: 'comPagination',
  props: {
    total: Number,
    pageSizeCount: Number,
  },
  watch: {
    total(val) {
      this.totalRecord = this.total
    }
  },
  data() {
    return {
      pageIndex: 1,
      pageSize: 10,
      totalRecord: this.total
    }
  },
  methods: {
    changePageIndex(num) {
      console.log('子组件方法--由父组件掉用')
      this.pageIndex = num || 1
    },

    handleChange(value) {
      const params = {
        pageIndex: value,
        pageSize: this.pageSizeCount || this.pageSize
      }
      this.$emit('getPaginationValue', params)
    }
  }
}
</script>

<style scoped>
</style>
